<template>
    <u-button v-bind="Object.assign({}, $attrs, $props)" :loading="currentLoading"
        @getphonenumber="$emit('getphonenumber', $event)" :disabled="currentLoading">
        <slot></slot>
    </u-button>
</template>
<script lang="ts" setup>
import { computed, ref } from 'vue';

const props = withDefaults(defineProps<{
    type: 'primary' | 'success' | 'info' | 'warning' | 'error',
    loading?: boolean | undefined,
    loadingText?: string
}>(), {
    type: 'primary',
    loadingText: '请求中...'
});
let selfLoading = ref(false)
let currentLoading = computed(() => {
    return props.loading || selfLoading.value
})
defineEmits(['getphonenumber'])

defineExpose({
    showLoading: () => selfLoading.value = true,
    hideLoading: () => selfLoading.value = false,
    loading: currentLoading
})

</script>
<style lang="scss" setup>
l-button {
    @apply block;
}
</style>